//
//  JHSTicklingCell.m
//  设置与帮助
//
//  Created by 卢春晖 on 2017/3/23.
//  Copyright © 2017年 itheima. All rights reserved.
//

#import "JHSTicklingCell.h"


@interface JHSTicklingCell ()<UITextViewDelegate>

@property (nonatomic, copy)NSString *examineText;

@property (nonatomic, weak)UILabel *uilabel;

@end


@implementation JHSTicklingCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}
-(void)setupUI{
    //首先定义UITextView
    UITextView *textView = [[UITextView alloc] init];
    textView.font = [UIFont systemFontOfSize:14];
    // textView.frame =CGRectMake(10, 0, self.contentView.bounds.size.width-20, side);
    //设置代理
    textView.delegate = self;
    
    textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    
    textView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:textView];
    textView.hidden = NO;
    
    //添加约束
    [textView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.offset(0);
        make.height.mas_equalTo(200);
    }];
    
    UILabel *uilabel = [[UILabel alloc]init];
    
    
    uilabel.frame =CGRectMake(17, 8, self.contentView.bounds.size.width - 10, 20);
    uilabel.text = @"请输入您宝贵的建议";
    uilabel.enabled = NO;//lable必须设置为不可用
    uilabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:uilabel];
    
    _uilabel = uilabel;
    
}

//实现UITextView的代理
-(void)textViewDidChange:(UITextView *)textView
{
    self.examineText = textView.text;
    if (textView.text.length == 0) {
        _uilabel.text = @"请输入您宝贵的建议.";
    }else{
        _uilabel.text = @"";
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
